/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * NewJFrame.java
 *
 * Created on 2011-5-5, 14:09:07
 */

package gui;

import entities.Group;
import gui_controller.Home_gui_controller;

import java.awt.AWTException;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.SystemTray;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.util.ArrayList;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;

import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JTabbedPane;
import javax.swing.ListModel;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;




/**
 *
 * @author wang
 */
public class Home extends javax.swing.JFrame implements Runnable{
	private static final String TRAYPATH = "./src/photo/1.jpg";
	private static final String PATH = "./icon/avator.jpg";
    private SystemTray sysTray;
    private TrayIcon trayIcon;
    private ImageIcon icon = null;
    //private Thread thread;
    private boolean flag;
    public void run() {
        //throw new UnsupportedOperationException("Not supported yet.");
       while (true){
        while(flag){
            System.out.print(flag);
            try {
                this.trayIcon.setImage(new ImageIcon("").getImage());
                Thread.sleep(500);
                this.trayIcon.setImage(icon.getImage());
                Thread.sleep(500);
                
            } catch (InterruptedException ex) {
                Logger.getLogger(Home.class.getName()).log(Level.SEVERE, null, ex);
            }
           // System.out.print(this.getClass().getName()+" stopped");
        }
        }
        
    }
    public void Flicker(){
        flag = true;
    }
    public void Stop() {
        flag = false;
    }
    public void addTrayIcon() {
		try {
			sysTray.add(trayIcon);// 将托盘添加到操作系统的托盘
			setVisible(false);    // 使得当前的窗口隐藏
			//new Thread(this).start();
		} catch (AWTException e1) {
			e1.printStackTrace();
		}
	}
    public void createTrayIcon() {
        sysTray = SystemTray.getSystemTray();// 获得当前操作系统的托盘对象
        icon = new ImageIcon(TRAYPATH);// 托盘图标
        trayIcon = new TrayIcon(icon.getImage(), "消息盒子");
        trayIcon.addMouseListener(new MouseAdapter() {
			public void mouseClicked(MouseEvent e) {
				if (e.getClickCount() ==2) {
                                    home_gui_controller.handleBlink();
                                   //Stop();
				}
			}
		});
    }
    /** Creates new form NewJFrame */
    public Home(Home_gui_controller home_gui_controller,ArrayList<Group> groups,String name,int whoareyou,String tweet) {
       // thread = new Thread(this);
        this.home_gui_controller = home_gui_controller;
       this.createTrayIcon(); //制作托盘
        addTrayIcon();//加载托盘
//        System.out.println("...");
        initComponents();//初始化
//        System.out.println(".....qqqqqqq.");
        RepaintComponent(groups); //初始化JTree和PopMenu
//        System.out.println("...");
        InitImageAndTweet(PATH,tweet,name);//初始化头像和状态
//        InitNews(false,0);//加载news
    
        


        if (whoareyou==0)
            SendNotice.setVisible(false);

       if (whoareyou==1)
    	   SendProject.setVisible(true);
       else
           SendProject.setVisible(false);

        if (whoareyou==2)
            Import.setVisible(true);
        else
            Import.setVisible(false);
       
        Flicker();//启用线程
    }
    public void setTweet(String tweet){    //更新状态后，调用此方法，立即显示新的状态
        jTextField1.setText(tweet);
    }
    private void InitImageAndTweet(String imagepath,String tweet,String name){
        jTextField1.setText(tweet);
        jLabel1.setText(name);
        ImageIcon img=new ImageIcon(imagepath);
        img.setImage(img.getImage().getScaledInstance(116, 81, Image.SCALE_DEFAULT));
        ImageButton.setIcon(img);
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        ImageButton = new javax.swing.JButton();
        SelfInfo = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        Tweet = new javax.swing.JButton();
        jTextField2 = new javax.swing.JTextField();
        SearchFriend = new javax.swing.JButton();
        UpLoadPhoto = new javax.swing.JButton();
        SendBlog = new javax.swing.JButton();
        SendProject = new javax.swing.JButton();
        SendActivity = new javax.swing.JButton();
        Import = new javax.swing.JButton();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        IM = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTree1 = new javax.swing.JTree();
        SNS = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        jButton4 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jPanel4 = new javax.swing.JPanel();
        jButton12 = new javax.swing.JButton();
        jButton14 = new javax.swing.JButton();
        jButton17 = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        jList2 = new javax.swing.JList();
        jPanel6 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jList3 = new javax.swing.JList();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        jList4 = new javax.swing.JList();
        jPanel5 = new javax.swing.JPanel();
        SendNotice = new javax.swing.JButton();
        jScrollPane6 = new javax.swing.JScrollPane();
        jList5 = new javax.swing.JList();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Lancet");

        jPanel1.setBackground(new java.awt.Color(51, 51, 51));

        ImageButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/photo/Avator.gif"))); // NOI18N
        ImageButton.setBorder(null);
        ImageButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ImageButtonMouseClicked(evt);
            }
        });

        SelfInfo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/photo/Self_Info.jpg"))); // NOI18N
        SelfInfo.setBorder(null);
        SelfInfo.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        SelfInfo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        SelfInfo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        SelfInfo.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                SelfInfoMouseClicked(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("华文细黑", 1, 18));
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Lancet");

        jTextField1.setText("说说啥吧");
        jTextField1.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        Tweet.setIcon(new javax.swing.ImageIcon(getClass().getResource("/photo/Tweet.jpg"))); // NOI18N
        Tweet.setBorder(null);
        Tweet.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                TweetMouseClicked(evt);
            }
        });

        jTextField2.setText("Search");
        jTextField2.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        SearchFriend.setIcon(new javax.swing.ImageIcon(getClass().getResource("/photo/Search.jpg"))); // NOI18N
        SearchFriend.setBorder(null);
        SearchFriend.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                SearchFriendMouseClicked(evt);
            }
        });

        UpLoadPhoto.setIcon(new javax.swing.ImageIcon(getClass().getResource("/photo/Upload Photos.jpg"))); // NOI18N
        UpLoadPhoto.setBorder(null);
        UpLoadPhoto.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                UpLoadPhotoMouseClicked(evt);
            }
        });

        SendBlog.setIcon(new javax.swing.ImageIcon(getClass().getResource("/photo/Write a Blog.jpg"))); // NOI18N
        SendBlog.setBorder(null);
        SendBlog.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                SendBlogMouseClicked(evt);
            }
        });

        SendProject.setIcon(new javax.swing.ImageIcon(getClass().getResource("/photo/Publish an Proj.jpg"))); // NOI18N
        SendProject.setBorder(null);
        SendProject.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                SendProjectMouseClicked(evt);
            }
        });

        SendActivity.setIcon(new javax.swing.ImageIcon(getClass().getResource("/photo/Initiate an Act.jpg"))); // NOI18N
        SendActivity.setAutoscrolls(true);
        SendActivity.setBorder(null);
        SendActivity.setPreferredSize(new java.awt.Dimension(100, 40));
        SendActivity.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                SendActivityMouseClicked(evt);
            }
        });

        Import.setIcon(new javax.swing.ImageIcon(getClass().getResource("/photo/AddnewUser.jpg"))); // NOI18N
        Import.setBorder(null);
        Import.setPreferredSize(new java.awt.Dimension(100, 40));
        Import.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ImportMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(ImageButton, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(29, 29, 29)
                                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 50, Short.MAX_VALUE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(SendBlog, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addComponent(UpLoadPhoto, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(SendActivity, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(SendProject, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addComponent(Import, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(SelfInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(SearchFriend, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(9, 9, 9))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 474, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(Tweet, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(UpLoadPhoto, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(ImageButton, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addGap(34, 34, 34)
                                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(SendBlog, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(Import, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(SelfInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addGap(32, 32, 32)
                                    .addComponent(SearchFriend, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addGap(43, 43, 43)
                                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(SendProject, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(SendActivity, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Tweet, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jTabbedPane1.setFont(new java.awt.Font("华文细黑", 0, 12));
        jTabbedPane1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTabbedPane1MouseClicked(evt);
            }
        });
        jTabbedPane1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jTabbedPane1StateChanged(evt);
            }
        });

        IM.setBackground(new java.awt.Color(51, 51, 51));
        IM.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                IMMouseClicked(evt);
            }
        });

        javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("root");
        jTree1.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
        jTree1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTree1MouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTree1);

        javax.swing.GroupLayout IMLayout = new javax.swing.GroupLayout(IM);
        IM.setLayout(IMLayout);
        IMLayout.setHorizontalGroup(
            IMLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(IMLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 722, Short.MAX_VALUE)
                .addContainerGap())
        );
        IMLayout.setVerticalGroup(
            IMLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(IMLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("IM", IM);

        SNS.setFont(new java.awt.Font("华文细黑", 0, 12));
        SNS.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                SNSStateChanged(evt);
            }
        });

        jPanel3.setBackground(new java.awt.Color(51, 51, 51));

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/photo/All.jpg"))); // NOI18N
        jButton4.setBorder(null);
        jButton4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton4MouseClicked(evt);
            }
        });

        jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/photo/Photos.jpg"))); // NOI18N
        jButton7.setBorder(null);
        jButton7.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton7MouseClicked(evt);
            }
        });

        jButton8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/photo/Blog_small.jpg"))); // NOI18N
        jButton8.setBorder(null);
        jButton8.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton8MouseClicked(evt);
            }
        });

        jButton11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/photo/Hot.jpg"))); // NOI18N
        jButton11.setBorder(null);
        jButton11.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton11MouseClicked(evt);
            }
        });

        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/photo/Tweet_small.jpg"))); // NOI18N
        jButton5.setBorder(null);
        jButton5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton5MouseClicked(evt);
            }
        });

        jList1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jList1MouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(jList1);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 611, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jButton5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 100, Short.MAX_VALUE)
                        .addComponent(jButton4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 100, Short.MAX_VALUE)
                        .addComponent(jButton7, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton8, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        SNS.addTab("News", jPanel3);

        jPanel4.setBackground(new java.awt.Color(51, 51, 51));

        jButton12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/photo/Tweet_small.jpg"))); // NOI18N
        jButton12.setBorder(null);
        jButton12.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton12MouseClicked(evt);
            }
        });

        jButton14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/photo/Blog_small.jpg"))); // NOI18N
        jButton14.setBorder(null);
        jButton14.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton14MouseClicked(evt);
            }
        });

        jButton17.setIcon(new javax.swing.ImageIcon(getClass().getResource("/photo/Photos.jpg"))); // NOI18N
        jButton17.setBorder(null);
        jButton17.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton17MouseClicked(evt);
            }
        });

        jList2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jList2MouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(jList2);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 611, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton14, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton17, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton14, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton17, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        SNS.addTab("Mine", jPanel4);

        jPanel6.setBackground(new java.awt.Color(51, 51, 51));

        jList3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jList3MouseClicked(evt);
            }
        });
        jScrollPane4.setViewportView(jList3);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 717, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE)
                .addContainerGap())
        );

        SNS.addTab("Project", jPanel6);

        jPanel2.setBackground(new java.awt.Color(51, 51, 51));

        jList4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jList4MouseClicked(evt);
            }
        });
        jScrollPane5.setViewportView(jList4);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 717, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE)
                .addContainerGap())
        );

        SNS.addTab("Activity", jPanel2);

        jPanel5.setBackground(new java.awt.Color(51, 51, 51));

        SendNotice.setIcon(new javax.swing.ImageIcon(getClass().getResource("/photo/Write a Notice.jpg"))); // NOI18N
        SendNotice.setBorder(null);
        SendNotice.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                SendNoticeMouseClicked(evt);
            }
        });

        jList5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jList5MouseClicked(evt);
            }
        });
        jScrollPane6.setViewportView(jList5);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(274, 274, 274)
                        .addComponent(SendNotice, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 717, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(SendNotice, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        SNS.addTab("Notice", jPanel5);

        jTabbedPane1.addTab("SNS", SNS);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jTabbedPane1, 0, 0, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 395, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    public void RepaintComponent(ArrayList<Group> groups){
        InitJTree(groups);
        InitPopMenu(groups);
    }
    public void InitPopMenu(ArrayList<Group> groups) {
    	menuitems = new ArrayList();
    	
    	
    	jpopupMenu2 = new JPopupMenu();
    	//jmenuItemAddFriend = new JMenuItem("添加好友");
    	jmenuItemAddGroup = new JMenuItem("新建组");
    	jmenuItemDeleteGroup = new JMenuItem("删除该组");
    	
    //	jpopupMenu2.add(jmenuItemAddFriend);
    	jpopupMenu2.add(jmenuItemAddGroup);
    	jpopupMenu2.add(jmenuItemDeleteGroup);
		// TODO Auto-generated method stub
    	jpopupMenu1 = new JPopupMenu();
    	
    	submenuMoveTo = new JMenu("将好友移动到...");
    	submenuCopyTo = new JMenu("将好友复制到...");
    	
      
        
        for (int i=0;i<groups.size();i++){
        	jmenuItem0 = new JMenuItem(groups.get(i).getGroup_name());
        	submenuMoveTo.add(jmenuItem0);
        	menuitems.add(jmenuItem0);
        	jmenuItem0.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                	jmenuItemActionPerformed(evt);
                }
            });
        }
        for (int i=0;i<groups.size();i++){
        	jmenuItem0 = new JMenuItem(groups.get(i).getGroup_name());
        	submenuCopyTo.add(jmenuItem0);
        	menuitems.add(jmenuItem0);
        	jmenuItem0.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                	jmenuItemActionPerformed(evt);
                }
            });
        }
        
        
       
        
        jmenuItemSelfInfo = new JMenuItem("查看信息");
        jmenuItemDelete = new JMenuItem("删除好友");
        
        
        jpopupMenu1.add(submenuMoveTo);
        jpopupMenu1.add(submenuCopyTo);
        jpopupMenu1.add(jmenuItemSelfInfo);
        jpopupMenu1.add(jmenuItemDelete);
        
     
        /*jmenuItemAddFriend.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	jmenuItemActionPerformed(evt);
            }
        }); */
        jmenuItemAddGroup.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	jmenuItemActionPerformed(evt);
            }
        }); 
        jmenuItemDeleteGroup.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	jmenuItemActionPerformed(evt);
            }
        }); 
        jmenuItemSelfInfo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	jmenuItemActionPerformed(evt);
            }
        }); 
        jmenuItemDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	jmenuItemActionPerformed(evt);
            }
        }); 
	}
    private void jmenuItemActionPerformed(ActionEvent evt) {
		// TODO Auto-generated method stub
    	
    	ArrayList<Group> groups = home_gui_controller.requestGroups();
    	for (int i=0;i<groups.size();i++){
         	if (evt.getSource()==menuitems.get(i)){
         		home_gui_controller.requestMoveTo(node.getParent().toString(),node.getInt(),groups.get(i).getGroup_name());
         		return;
         	}
        }
    	for (int i=groups.size();i<2*groups.size();i++){
         	if (evt.getSource()==menuitems.get(i)){
         		home_gui_controller.requestCopyTo(node.getParent().toString(),node.getInt(),groups.get(i).getGroup_name());
         		return;
         	}
        }
        if (evt.getSource()==jmenuItemAddGroup){
    		String name = JOptionPane.showInputDialog("组名： "); 
    		if (name==null) return;
                    home_gui_controller.requestAddGroup(name);
    	}else if(evt.getSource()==jmenuItemDeleteGroup){
    		home_gui_controller.requestRemoveGroup(node.toString());
                return;
    	}else if (evt.getSource()==jmenuItemSelfInfo){
			//new SelfInfo().setVisible(true);
                        home_gui_controller.requestViewOtherSelfInfo(node.getInt());   //设置一些空间不可见
			return;
		}else if (evt.getSource()==jmenuItemDelete){
			//System.out.print("delete");
			home_gui_controller.requestDeleteFriend(node.getParent().toString(),node.getInt());
		}
		
	}
    
    public void InitJTree(ArrayList<Group> groups) {
		// TODO Auto-generated method stub
		//只要把groups给我，我就能建出好友分组列表
    	MyNode treeNode1 = new MyNode("我的好友");
    	
    	MyNode Nodes;
    	
    	MyNode tempNode;
    	
    	for (int i=0;i<groups.size();i++){
    		Nodes = new MyNode(groups.get(i).getGroup_name());
    		treeNode1.add(Nodes);
    		for(int j=0;j<groups.get(i).getGroup_size();j++){
            String name = home_gui_controller.get_friend_name(groups.get(i).getGroup_member().get(j));
            System.out.println("好友名字:"+name);
    			tempNode = new MyNode(name);
            tempNode.setInt(groups.get(i).getGroup_member().get(j));
    			Nodes.add(tempNode);
    		}
    	}

        jTree1.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
       
	}

    public void Shutdown(){
        JOptionPane.showMessageDialog(this, "掉线","消息",JOptionPane.INFORMATION_MESSAGE);
    }
    public void Init(ArrayList<String> news,int i){
        DefaultListModel model = new DefaultListModel();
//        System.out.print("www");
        for(Object t:news)
            model.addElement(t);
        switch (i)
        {
            case 1:jList1.setModel(model);
            break;
            case 2:jList2.setModel(model);
            break;
            case 3:jList3.setModel(model);
            break;
            case 4:jList4.setModel(model);
            break;
            case 5:jList5.setModel(model);
            break;
        }
        
    }

    

   // private void GuestLabelMouse
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                  
        // TODO add your handling code here:
       home_gui_controller.requestSelfInfo();
    }                                        

    private void TweetMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TweetMouseClicked
        // TODO add your handling code here:
        home_gui_controller.requestTweet(jTextField1.getText());
    }//GEN-LAST:event_TweetMouseClicked

    private void ImageButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ImageButtonMouseClicked
        // TODO add your handling code here:
        jFileChooser = new JFileChooser();
        int result = jFileChooser.showOpenDialog(this);
        if (result == jFileChooser.APPROVE_OPTION) {
            System.out.print("打开文件");
            File file = jFileChooser.getSelectedFile();
            home_gui_controller.requestChangeImage(file.getPath());
            

        }else{
            System.out.print("关闭文件");
        }
    }//GEN-LAST:event_ImageButtonMouseClicked
    public void RefreshIcon(){
        ImageIcon img=new ImageIcon(PATH);
        img.setImage(img.getImage().getScaledInstance(140, 160, Image.SCALE_DEFAULT));
        ImageButton.setIcon(img);
    }
    private void UpLoadPhotoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_UpLoadPhotoMouseClicked
        // TODO add your handling code here:
        home_gui_controller.requestUpLoadPhoto();
    }//GEN-LAST:event_UpLoadPhotoMouseClicked

    private void SendBlogMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SendBlogMouseClicked
        // TODO add your handling code here:

        home_gui_controller.requestSendBlog();
    }//GEN-LAST:event_SendBlogMouseClicked

    private void jTree1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTree1MouseClicked
        // TODO add your handling code here:
        int row = jTree1.getRowForLocation(evt.getX(),evt.getY());

        if(row == -1) return;

        if(evt.getClickCount() == 2) {
        
        TreePath path = jTree1.getPathForLocation(evt.getX(), evt.getY());
        node = (MyNode)path.getLastPathComponent();
        	if (node.isLeaf()){
        		
                        home_gui_controller.requestDialog(node.getInt());
        		return;
        	}
        }


        int mods=evt.getModifiers();
        if((mods&InputEvent.BUTTON3_MASK)!=0){
        //判断是不是右击
            TreePath path = jTree1.getPathForLocation(evt.getX(), evt.getY());
            node = (MyNode)path.getLastPathComponent();
            if (node.isLeaf()){
            	//System.out.print("www");
            	jpopupMenu1.show(evt.getComponent(),evt.getX(),evt.getY());
            	return;
            }else if (!node.isRoot()){
            	//System.out.print("www22");
            	jpopupMenu2.show(evt.getComponent(),evt.getX(),evt.getY());
            	return;
            }
        }
        
    }//GEN-LAST:event_jTree1MouseClicked

    private void SelfInfoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SelfInfoMouseClicked
        // TODO add your handling code here:
        home_gui_controller.requestSelfInfo();
    }//GEN-LAST:event_SelfInfoMouseClicked

    private void jButton4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton4MouseClicked
        // TODO add your handling code here:
        InitNews(false,0);
    }//GEN-LAST:event_jButton4MouseClicked

    private void jButton5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton5MouseClicked
        // TODO add your handling code here:
        InitNews(false,1);
    }//GEN-LAST:event_jButton5MouseClicked

    private void jButton8MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton8MouseClicked
        // TODO add your handling code here:
        InitNews(false,2);
    }//GEN-LAST:event_jButton8MouseClicked

    private void jButton7MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton7MouseClicked
        // TODO add your handling code here:
        InitNews(false,3);
    }//GEN-LAST:event_jButton7MouseClicked

    private void jTabbedPane1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTabbedPane1MouseClicked
        // TODO add your handling code here:
       // System.out.println(evt.getSource().toString());
    }//GEN-LAST:event_jTabbedPane1MouseClicked

    private void jButton11MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton11MouseClicked
        // TODO add your handling code here:
        InitNews(false,4);
    }//GEN-LAST:event_jButton11MouseClicked

    private void jButton12MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton12MouseClicked
        // TODO add your handling code here:
        InitMine(true,1);
    }//GEN-LAST:event_jButton12MouseClicked

    private void jButton14MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton14MouseClicked
        // TODO add your handling code here:
        InitMine(true,2);
    }//GEN-LAST:event_jButton14MouseClicked

    private void jButton17MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton17MouseClicked
        // TODO add your handling code here:
        InitMine(true,3);
    }//GEN-LAST:event_jButton17MouseClicked

    private void jTabbedPane1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedPane1StateChanged
        // TODO add your handling code here:
  
        JTabbedPane sourceTabbedPane = (JTabbedPane) evt.getSource();
        int index = sourceTabbedPane.getSelectedIndex();
        ArrayList<Group> groups = home_gui_controller.requestGroups();
        if (index==0){
            InitJTree(groups);
        }else {
        	
            InitNews(false,0);
        }
    }//GEN-LAST:event_jTabbedPane1StateChanged

    private void IMMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_IMMouseClicked
        // TODO add your handling code here:
       // System.out.print("Sns");
    }//GEN-LAST:event_IMMouseClicked

    private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked
        // TODO add your handling code here:
        int index = jList1.locationToIndex(evt.getPoint()); //得到具体哪条状态
        home_gui_controller.requestDetail(false,0,index);  //弹窗显示
    }//GEN-LAST:event_jList1MouseClicked

    private void jList2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList2MouseClicked
        // TODO add your handling code here:
        int index = jList2.locationToIndex(evt.getPoint());
        home_gui_controller.requestDetail(true,0,index);
    }//GEN-LAST:event_jList2MouseClicked

    private void jList3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList3MouseClicked
        // TODO add your handling code here:
        int index = jList3.locationToIndex(evt.getPoint());
        home_gui_controller.requestProject(index);
    }//GEN-LAST:event_jList3MouseClicked

    private void jList4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList4MouseClicked
        // TODO add your handling code here:
        int index = jList4.locationToIndex(evt.getPoint());
        System.out.print("选择了第"+index+"条活动");
        home_gui_controller.requestActivity(index);
    }//GEN-LAST:event_jList4MouseClicked

    private void jList5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList5MouseClicked
        // TODO add your handling code here:
        int index = jList5.locationToIndex(evt.getPoint());
        home_gui_controller.requestNotice(index);
    }//GEN-LAST:event_jList5MouseClicked

    private void SNSStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_SNSStateChanged
        // TODO add your handling code here:
        JTabbedPane sourceTabbedPane = (JTabbedPane) evt.getSource();
        int index = sourceTabbedPane.getSelectedIndex();
        switch (index)
        {
            case 0:
                InitNews(false,0);
                break;
            case 1:
                InitMine(true,1);
                break;
            case 2:
                InitProject();
                break;
            case 3:
                InitActivity();
                break;
            case 4:
                InitNotice();
                break;
        }

    }//GEN-LAST:event_SNSStateChanged

    private void SearchFriendMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SearchFriendMouseClicked
        // TODO add your handling code here:
        home_gui_controller.requestSearch(jTextField2.getText());
    }//GEN-LAST:event_SearchFriendMouseClicked

    private void SendProjectMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SendProjectMouseClicked
        // TODO add your handling code here:
        home_gui_controller.requestSendProject();
    }//GEN-LAST:event_SendProjectMouseClicked

    private void SendActivityMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SendActivityMouseClicked
        // TODO add your handling code here:
        home_gui_controller.requestSendActivity();
    }//GEN-LAST:event_SendActivityMouseClicked

    private void ImportMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ImportMouseClicked
        // TODO add your handling code here:
        home_gui_controller.requestImport();
    }//GEN-LAST:event_ImportMouseClicked

    private void SendNoticeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SendNoticeMouseClicked
        // TODO add your handling code here:
        home_gui_controller.requestSendNotice();
    }//GEN-LAST:event_SendNoticeMouseClicked
    /*public static void main(String args[]){
         Home h = new Home();
         new Thread(h).start();
         h.setVisible(true);
         
      

    }*/

    /**
    * @param args the command line arguments
    */
    private MyNode node;
    //private ArrayList<Group> groups;
    private javax.swing.JFileChooser jFileChooser;
    private JPopupMenu jpopupMenu1,jpopupMenu2;
    private JMenu submenuMoveTo,submenuCopyTo;    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel IM;
    private javax.swing.JButton ImageButton;
    private javax.swing.JButton Import;
    private javax.swing.JTabbedPane SNS;
    private javax.swing.JButton SearchFriend;
    private javax.swing.JButton SelfInfo;
    private javax.swing.JButton SendActivity;
    private javax.swing.JButton SendBlog;
    private javax.swing.JButton SendNotice;
    private javax.swing.JButton SendProject;
    private javax.swing.JButton Tweet;
    private javax.swing.JButton UpLoadPhoto;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton17;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JList jList1;
    private javax.swing.JList jList2;
    private javax.swing.JList jList3;
    private javax.swing.JList jList4;
    private javax.swing.JList jList5;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTree jTree1;
    // End of variables declaration//GEN-END:variables
    ArrayList<JMenuItem> menuitems;
    ArrayList<JPanel> News;
    ArrayList<JPanel> Mine;
    ArrayList<JPanel> Notice;
    ArrayList<JPanel> Project;
    ArrayList<JPanel> Activity;
    private JMenuItem jmenuItem0,jmenuItemAddFriend,jmenuItemAddGroup,jmenuItemDeleteGroup,jmenuItemSelfInfo,jmenuItemDelete,jmenuItemDialogToAll;
    private Home_gui_controller home_gui_controller;

    private void InitMine(boolean b, int i) {
       // throw new UnsupportedOperationException("Not yet implemented");
       home_gui_controller.requestMine(b,i);
    }

    private void InitNews(boolean b, int i) {
        //throw new UnsupportedOperationException("Not yet implemented");
    		System.out.println("type:"+i);
    }
   

    

    

    private void InitProject() {
       // throw new UnsupportedOperationException("Not yet implemented");
        home_gui_controller.requestProject();
    }

    private void InitActivity() {
       // throw new UnsupportedOperationException("Not yet implemented");
        home_gui_controller.requestActivity();
    }

    private void InitNotice() {
        //throw new UnsupportedOperationException("Not yet implemented");
        home_gui_controller.requestNotice();
    }

    
}
